package tuiLayer;
import java.util.Scanner;
import controlLayer.*;
import modelLayer.*;
import java.util.Date;
public class DVDUI
{
    private DVDController dvdCon;
    public DVDUI()
    {
        
    }
    public void dvdMenu()
    {        
       dvdCon = new DVDController();
       boolean exit = false;
       while(!exit)//that is: while exit is false
       {
           String choise = subMenus();
           switch(choise)
           {
               case "1":
               System.out.println(" (1) Create DVD");
               creatDVD();
               break;
               case "2": 
               System.out.print('\u000C');
               System.out.println(" (2) Update DVD");   
               updateDVD();
               break;
               case "3":
               System.out.print('\u000C');
               System.out.println(" (3) Delete DVD");   
               removeDvd();
               break;
               case "4":
               System.out.print('\u000C');
               System.out.println(" (4) Find DVD");
               findDvd();
               break;
               case "5": 
               exit = true;
               break;
           }
       }
    }
    
    public void creatDVD()
    {
       // int barcode, String title, String artist, Date publictionDate
        System.out.print('\u000C'); 
        System.out.println("*** DVD Menu ***");
        Scanner keyboard = new Scanner(System.in);
        System.out.println("set barcode");
        int barcode = keyboard.nextInt();
        
        System.out.println("set title");
        String indTitel = keyboard.next();
        
        System.out.println("set artist");
        String indartist = keyboard.next();
        
        System.out.println("set publictionDate");
        String indpublictionDate = keyboard.next();
        
        DVDController dvdCon = new DVDController();
        System.out.println("want to add copys (1) yes --- (2)no");
        int copychoos = keyboard.nextInt();
        if(copychoos == 1)
        {
           System.out.println("how many?");
           int amount = keyboard.nextInt();
           dvdCon.createDvd(barcode, indTitel, indartist, indpublictionDate, amount);
        }
        else
        {
             dvdCon.createDvd(barcode, indTitel, indartist, indpublictionDate, 0);
        }
    }
    public void findDvd()
    {
        dvdCon.findDvd(settitle());
    }
    public void updateDVD()
    {
        dvdCon.updateDVD(settitle());
    }
    public void removeDvd()
    {
        dvdCon.removeDvd(settitle());
    }
    public String settitle()
    {
        Scanner keyboard = new Scanner(System.in);        
        System.out.println("Enter title");
        String indTitel = keyboard.next();
        return indTitel;
    }
    
    public String subMenus()
    {      // makes an object keyboard to read input from the screen
       Scanner keyboard = new Scanner(System.in);
       System.out.print('\u000C');
       System.out.println("*** DVD Menu ***");
       System.out.println(" (1) Create DVD");
       System.out.println(" (2) Update DVD");
       System.out.println(" (3) Delete DVD");
       System.out.println(" (4) Find DVD");
       System.out.println(" (5) back");
       System.out.print("\n choose: ");
            
       String choise = keyboard.next();
       return choise;
    }
}
